import requests

#1)利用session发送德鲁请求
url_login='https://gitee.com/'
#user_agent请求头
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36'
}
data = {
'encrypt_key': 'password',
'utf8': '✓',
'authenticity_token': 'CuOr8Ia5lXxC0sEVZrM50YhSDLvf0Uvm0utdoJDI4gM=',
'redirect_to_url': '',
'user[login]': '2844369248@qq.com',
'encrypt_data[user[password]]': 'N0o2jgBzlK5d3hwRO2DsoaxTrqdayILwfqrd+CQ1/MMX8v1sUszn4zIqxPX1MH2M9DIGco81bXGGw0Z1L/WQgJQ6neEdX8G3ckTyBojjwOEsX6Oxk3xOTzaeKiJ2UqYEPLkypyAW9V+ILOK9uNJOVgoF1S8ySevBj7spxJOpG6I=',
'user[remember_me]': '0'
}
#发送登录请求的post请求，改成用session来发送，可以实现状态保持
session=requests.session()
r=session.post(url_login,headers=headers,data=data)
print(r.status_code)
print(r.content.decode())
print('*******************************')
#2)利用session发送 登录后才能访问的页面，不需要加cookie
url='https://gitee.com/'
r2=session.get(url,headers=headers)
print(r2.content.decode())


